<template>
  <el-menu
  
    style="height: 100%;overflow: hidden;"
    background-color="#545c64"
    text-color="#fff"
    active-text-color="#ffd04b"
    router
  >
     <h3>选课管理系统</h3>
    <!-- <span style="color: white" class="title">后台管理系统</span>
          <el-submenu index="1">
            <template slot="title"
              ><i class="el-icon-house"></i>主页管理</template
            >
            <el-menu-item-group>
              
              <el-menu-item index="/main" >主页</el-menu-item>
              
            </el-menu-item-group>
            </el-submenu>
         
          <el-submenu index="2">
            <template slot="title"><i class="el-icon-menu"></i>系统管理</template>
            <el-menu-item-group>
              <el-menu-item index="/user">用户管理</el-menu-item>
              <el-menu-item index="/file">文件管理</el-menu-item>
              <el-menu-item index="/role">角色管理</el-menu-item>
              <el-menu-item index="/menu">菜单管理</el-menu-item>
            </el-menu-item-group>
           
          
          </el-submenu> -->

    <div v-for="item in menus" :key="item.id">
      <!-- 只有一级菜单 -->
      <div v-if="item.path">
        <el-menu-item :index="item.path">
          <i :class="item.icon"></i>
          <span slot="title">{{ item.name }}</span>
        </el-menu-item>
      </div>
      <!-- 拥有二级菜单 -->
      <div v-else>
        <el-submenu :index="item.id + ''">
          <template slot="title">
            <i :class="item.icon"></i>
            <span slot="title">{{ item.name }}</span>
          </template>
          <div v-for="subitem in item.children" :key="subitem.id">
            <el-menu-item :index="subitem.path">
              <i :class="subitem.icon"></i>
              <span slot="title">{{ subitem.name }}</span>
            </el-menu-item>
          </div>
        </el-submenu>
      </div>
    </div>
  </el-menu>
</template>
<script>
export default {
  name: "Aside",
  data() {
    return {
      menus: localStorage.getItem("menus")
        ? JSON.parse(localStorage.getItem("menus"))
        : [],
      opens: localStorage.getItem("menus")
        ? JSON.parse(localStorage.getItem("menus")).map((V) => V.id + "")
        : [],
    };
  },
};
</script>
<style scoped>
h3 {
  color: #fff;
  text-align: center;
  line-height: 48px;
  white-space: nowrap;
}
</style>